/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.mycompany.psc.entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author A7med
 */
@Entity
@Table(name = "projects")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Projects.findAll", query = "SELECT p FROM Projects p"),
    @NamedQuery(name = "Projects.findOther", query = "SELECT p FROM Projects p where p.id != :id"),
    @NamedQuery(name = "Projects.findById", query = "SELECT p FROM Projects p WHERE p.id = :id"),
    @NamedQuery(name = "Projects.findByName", query = "SELECT p FROM Projects p WHERE p.name = :name")})
public class Projects implements Serializable {
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "project")
    private List<Carpenter> carpenterList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "projectId")
    private List<MetalDoors> metalDoorsList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "project")
    private List<Aluminium> aluminiumList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "project")
    private List<SiteExpenses> siteExpensesList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "project")
    private List<Mobilization> mobilizationList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "project")
    private List<TenderItems> tenderItemsList;
  
    

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 64)
    @Column(name = "name")
    private String name;
    @Basic(optional = false)
    @NotNull
    @Lob
    @Size(min = 1, max = 65535)
    @Column(name = "description")
    private String description;
    @ManyToMany(mappedBy = "projectsList")
    private List<Users> users;

    public Projects() {
    }

    public Projects(Integer id) {
        this.id = id;
    }

    public Projects(Integer id, String name, String desc) {
        this.id = id;
        this.name = name;
        this.description = desc;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

   

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Projects)) {
            return false;
        }
        Projects other = (Projects) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.mycompany.psc.controllers.Projects[ id=" + id + " ]";
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public List<Users> getUsers() {
        return users;
    }

    public void setUsers(List<Users> users) {
        this.users = users;
    }

    @XmlTransient
    public List<TenderItems> getTenderItemsList() {
        return tenderItemsList;
    }

    public void setTenderItemsList(List<TenderItems> tenderItemsList) {
        this.tenderItemsList = tenderItemsList;
    }

    @XmlTransient
    public List<SiteExpenses> getSiteExpensesList() {
        return siteExpensesList;
    }

    public void setSiteExpensesList(List<SiteExpenses> siteExpensesList) {
        this.siteExpensesList = siteExpensesList;
    }

    @XmlTransient
    public List<Mobilization> getMobilizationList() {
        return mobilizationList;
    }

    public void setMobilizationList(List<Mobilization> mobilizationList) {
        this.mobilizationList = mobilizationList;
    }

    @XmlTransient
    public List<Aluminium> getAluminiumList() {
        return aluminiumList;
    }

    public void setAluminiumList(List<Aluminium> aluminiumList) {
        this.aluminiumList = aluminiumList;
    }

    @XmlTransient
    public List<MetalDoors> getMetalDoorsList() {
        return metalDoorsList;
    }

    public void setMetalDoorsList(List<MetalDoors> metalDoorsList) {
        this.metalDoorsList = metalDoorsList;
    }

    @XmlTransient
    public List<Carpenter> getCarpenterList() {
        return carpenterList;
    }

    public void setCarpenterList(List<Carpenter> carpenterList) {
        this.carpenterList = carpenterList;
    }

   

}
